package com.yazi.mxz.mobile.jackson.filter;

import java.util.HashSet;
import java.util.Set;

import com.fasterxml.jackson.databind.ser.FilterProvider;
import com.fasterxml.jackson.databind.ser.impl.SimpleBeanPropertyFilter;
import com.fasterxml.jackson.databind.ser.impl.SimpleFilterProvider;
import com.yazi.mxz.common.entity.beans.Address;
import com.yazi.mxz.common.entity.beans.Member;
import com.yazi.mxz.common.entity.beans.SecurityQuestion;

public abstract class MemberFilter {

	public static FilterProvider getWithDefAddressAndAddresses() {
		final Set<String> member = new HashSet<String>();
		member.add("address");
		member.add("addresses");
		final Set<String> address = new HashSet<String>();
		address.add("addressId");
		address.add("alias");
		address.add("consignee");
		address.add("mobile");
		address.add("regionName");
		address.add("street");

		FilterProvider fp = new SimpleFilterProvider().addFilter(Member.class.getSimpleName(),
				SimpleBeanPropertyFilter.filterOutAllExcept(member))
				.addFilter(Address.class.getSimpleName(),
						SimpleBeanPropertyFilter.filterOutAllExcept(address));

		return fp;
	}

	public static FilterProvider get4Edit() {
		final Set<String> member = new HashSet<String>();
		member.add("name");
		member.add("sex");
		member.add("realName");
		member.add("mobile");
		member.add("email");
		member.add("birthday");
		member.add("regionId");
		member.add("street");

		FilterProvider fp = new SimpleFilterProvider().addFilter(Member.class.getSimpleName(),
				SimpleBeanPropertyFilter.filterOutAllExcept(member));

		return fp;
	}

	public static FilterProvider get4Loginfo() {
		final Set<String> member = new HashSet<String>();
		member.add("name");
		member.add("realName");

		FilterProvider fp = new SimpleFilterProvider().addFilter(Member.class.getSimpleName(),
				SimpleBeanPropertyFilter.filterOutAllExcept(member));

		return fp;
	}

	public static FilterProvider get4ForgetPwd() {
		final Set<String> member = new HashSet<String>();
		member.add("mobile");
		member.add("email");
		member.add("securityQuestions");
		// securityQuestion
		final Set<String> securityQuestion = new HashSet<String>();
		securityQuestion.add("questionId");
		securityQuestion.add("question");

		FilterProvider fp = new SimpleFilterProvider().addFilter(Member.class.getSimpleName(),
				SimpleBeanPropertyFilter.filterOutAllExcept(member)).addFilter(
				SecurityQuestion.class.getSimpleName(),
				SimpleBeanPropertyFilter.filterOutAllExcept(securityQuestion));

		return fp;
	}
}
